loadstring(exports.dgs:dgsImportFunction())()
dgsLocateObjectPreviewResource("object_preview")

local sw,sh = guiGetScreenSize()
local px,py = sw/1366,sh/768
cmtaPANELGRACZA = false
font = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 12*px )
font2 = dgsCreateFont( ":cmta-pobieraniezasobow/OSB.ttf", 20*px )
achimg1 = dxCreateTexture( "ekwipunek/papierosy.png" ,"argb", false, "clamp" )

shadery = {
    {"shader:1","Shader Odbicia Pojazdów"},
    {"shader:2","Shader Woda"},
    {"shader:3","Shader Bloom"},
    {"shader:4","Shader Rozmycie"},
    {"shader:5","Shader Ślady Opon"},
    {"shader:6","Shader Detale"},
    {"shader:7","Shader Niebo"},
    {"shader:8","Shader Niskie Detale #ff0000(należy używać bez innych shaderów)"},
    {"shader:fps","Licznik FPS"},
    {"shader:renderowanie","Daleka Widoczność"},
    {"shader:ukrycie","Ukrycie Hudu"}

}

local xml = xmlLoadFile("shadery.xml")
if not xml then
	xml = xmlCreateFile("shadery.xml","graphic")
end

addEvent("cmta_panelgracza:achievements", true)
addEventHandler("cmta_panelgracza:achievements", resourceRoot, function(result)
  if not isElement(gridlistachievements) then return end
  dgsGridListClear(gridlistachievements)
  for i,v in pairs(result) do
    for _,x in pairs(fromJSON(v["achievements"])) do
        local row = dgsGridListAddRow ( gridlistachievements )
        dgsGridListSetItemImage( gridlistachievements, row, 1, achimg1,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistachievements, row, 2, x[1])
        dgsGridListSetItemText ( gridlistachievements, row, 3, x[2])
  end
end
 -- for i,v in pairs(result) do

  --  local row = dgsGridListAddRow ( gridlistachievements )
   --     dgsGridListSetItemText ( gridlistachievements, row, 1, v)
   --     dgsGridListSetItemText ( gridlistachievements, row, 2, )
  -- end

  --for i,v in ipairs(result) do
   -- if v["firstcar"] == 1 then
   --     dgsCreateLabel(5*px,0*py,594*px,30*py,"Pierwszy samochód +15PO",false,scrollpanel)
    --    dgsCreateLabel(5*px,0*py,594*px,30*py,"Pierwszy samochód +125PO",false,scrollpanel)
   -- end
    --outputChatBox(v[i])
    --if v["cigarettes"] > 0 then
   --     local row = dgsGridListAddRow ( gridlistinventory )
  --      dgsGridListSetItemImage( gridlistinventory, row, 1, invimg1,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
  --      dgsGridListSetItemText ( gridlistinventory, row, 2, "Papierosy" )
  --      dgsGridListSetItemText ( gridlistinventory, row, 3, v["cigarettes"] )
  --  end


--for id,child in ipairs(dgsGetChildren(scrollpanel)) do
  --  dgsSetFont( child, font2 )
 ---   dgsSetProperty(child,"alignment",{"center","center"})
 --   dgsSetPosition ( child, 0*px, id*40*py, false )
--end
if isElement(scrollpanel) then dgsSetVisible(scrollpanel,true) end
end)

function panel()
    if not getElementData(localPlayer,"player:data").uid then return end
    if isConsoleActive() then return end
    if cmtaPANELGRACZA == true then
        if dgsGetEnabled(rect1) == false then return end
        removeEventHandler ( "onDgsMouseClick", getRootElement(), onclick)
        removeEventHandler  ("onDgsComboBoxSelect",getRootElement(),onselected)
        cmtaPANELGRACZA = false 
        showCursor(false)
        if isElement(pedimg) then
            if isElement(skin) then destroyElement(skin) end
            dgsRemoveObjectPreviewFromImage(pedimg)
            exports.object_preview:destroyObjectPreview(objPrev)
            destroyElement(pedimg)
            end
        if isElement(vehimg) then
            if isElement(veh) then destroyElement(veh) end
            dgsRemoveObjectPreviewFromImage(vehimg)
            exports.object_preview:destroyObjectPreview(vehPrev)
            destroyElement(vehimg)
        end
        destroyElement(rndRect)
        destroyElement(rndRect2)
        destroyElement(rect1)
        destroyElement(rect2)
        destroyElement(blurimg)
        destroyElement(blurbox)
        if isElement(recttest) then destroyElement(recttest) destroyElement(rndTest) end
    else
    blurbox = dgsCreateBlurBox(600, 500)
    blurimg = dgsCreateImage(0*px,0*py,1366*px,768*py,blurbox,false)
    dgsBlurBoxSetIntensity(blurbox, 2)
    dgsSetEnabled ( blurimg, false )
    rndRect = dgsCreateRoundRect(30,false,tocolor(30,30,30,210))  
    rndRect2 = dgsCreateRoundRect(0,false,tocolor(30,30,30,210))  
    rect1 = dgsCreateImage(250*px,150*py,200*px,468*py,rndRect2,false)
    rect2 = dgsCreateImage(460*px,150*py,646*px,468*py,rndRect,false)     
    scrollpanel = dgsCreateScrollPane(20*px,50*py,606*px,368*py,false,rect2)
    dgsSetVisible(scrollpanel,false)
    combobox = dgsCreateComboBox(200*px,30*py,246*px,20*py,"Wybierz samochód",false,rect2)
    dgsSetVisible(combobox,false)
    dgsSetAlpha(rect1,0)
    dgsSetAlpha(rect2,0)
    dgsScrollPaneSetScrollBarState(scrollpanel,true,false)
    button = dgsCreateButton( 10*px, 20*py, 180*px, 40*py, "Informacje", false,rect1,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(255,0,0,90))
    button2 = dgsCreateButton( 10*px, 70*py, 180*px, 40*py, "Pojazdy", false,rect1,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(255,0,0,90))
    button3 = dgsCreateButton( 10*px, 120*py, 180*px, 40*py, "Kartoteka", false,rect1,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(255,0,0,90))
    button4 = dgsCreateButton( 10*px, 170*py, 180*px, 40*py, "Osiągnięcia", false,rect1,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(255,0,0,90))
    button5 = dgsCreateButton( 10*px, 220*py, 180*px, 40*py, "Ekwipunek", false,rect1,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(255,0,0,90))
    button5ab = dgsCreateButton( 10*px, 270*py, 180*px, 40*py, "Kody bonusowe", false,rect1,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(255,0,0,90))
    button5b = dgsCreateButton( 10*px, 320*py, 180*px, 40*py, "Ustawienia", false,rect1,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(255,0,0,90))
    dgsAlphaTo(rect1,255,false,"OutQuad",2000)
    dgsAlphaTo(rect2,255,false,"OutQuad",2000)
    text2 = dgsCreateLabel(20*px,200*py,366*px,50*py,"",false,rect2)
    dgsSetFont( text2, font )
    dgsSetProperty(text2,"colorcoded",true)
    dgsSetProperty(text2,"alignment",{"left","center"})
    dgsSetVisible(text2,false)
    button6 = dgsCreateButton( 100*px, 350*py, 180*px, 40*py, "Kluczyki", false,rect2,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
    dgsSetVisible(button6,false)
    button7 = dgsCreateButton( 366*px, 350*py, 180*px, 40*py, "Historia pojazdu", false,rect2,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
    dgsSetVisible(button7,false)
    
    showCursor(true)
    text = dgsCreateLabel(200*px,200*py,366*px,50*py,"",false,rect2)
    dgsSetFont( text, font )
    dgsSetProperty(text,"colorcoded",true)
    dgsSetProperty(text,"alignment",{"left","center"})
    dgsSetVisible(text,false)
    

    cmtaPANELGRACZA = true
    addEventHandler ( "onDgsMouseClick", getRootElement(), onclick)
    addEventHandler  ("onDgsComboBoxSelect",getRootElement(),onselected)
end

end
bindKey ("F3", "down", panel)

function removegui()
    dgsSetProperty(button,"color",{tocolor(90,90,90),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    dgsSetProperty(button2,"color",{tocolor(90,90,90),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    dgsSetProperty(button3,"color",{tocolor(90,90,90),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    dgsSetProperty(button4,"color",{tocolor(90,90,90),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    dgsSetProperty(button5,"color",{tocolor(90,90,90),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    dgsSetProperty(button5ab,"color",{tocolor(90,90,90),tocolor(210,105,30,255),tocolor(210,105,30,255)}) 
    dgsSetProperty(button5b,"color",{tocolor(90,90,90),tocolor(210,105,30,255),tocolor(210,105,30,255)}) 
    dgsSetVisible(text,false)
    dgsSetVisible(scrollpanel,false)
    dgsSetVisible(combobox,false)
    dgsSetVisible(text2,false)
    dgsSetText(text2,"")
    dgsSetVisible(button6,false)
    dgsSetVisible(button7,false)
    if isElement(button14) then destroyElement(button14) end
    if isElement(button15) then destroyElement(button15) end
    if isElement(button18) then destroyElement(button18); destroyElement(labelcodes); destroyElement(edit3) end
    if isElement(gridlistinventory) then destroyElement(gridlistinventory) end
    if isElement(gridlistachievements) then destroyElement(gridlistachievements) end
    if isElement(gridlist2) then destroyElement(gridlist2) end
    if isElement(recttest) then 
        for id,child in ipairs(dgsGetChildren(recttest)) do
            destroyElement(child)
        end
        destroyElement(recttest)
        destroyElement(rndTest)
    end
    if isElement(pedimg) then
    if isElement(skin) then destroyElement(skin) end
    dgsRemoveObjectPreviewFromImage(pedimg)
    exports.object_preview:destroyObjectPreview(objPrev)
    destroyElement(pedimg)
    end
    if isElement(vehimg) then
        if isElement(veh) then destroyElement(veh) end
        dgsRemoveObjectPreviewFromImage(vehimg)
        exports.object_preview:destroyObjectPreview(vehPrev)
        destroyElement(vehimg)
    end

end

function onclick ( btn, state )
    if btn == "left" and state == "down" and cmtaPANELGRACZA == true then
if source == button then
    removegui()
    dgsSetProperty(button,"color",{tocolor(210,105,30,255),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    dgsSetVisible(text,true)
    triggerServerEvent("cmta_panelgracza:getplayerinfo", resourceRoot)
end
if source == button2 then
    removegui()
    dgsSetProperty(button2,"color",{tocolor(210,105,30,255),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    dgsSetVisible(combobox,true)
    dgsSetVisible(text2,true)
    dgsComboBoxClear ( combobox )
    dgsComboBoxSetSelectedItem(combobox,-1)
    triggerServerEvent("cmta_panelgracza:getvehicles", resourceRoot)
end
if source == button3 then
    removegui()
    dgsSetProperty(button3,"color",{tocolor(210,105,30,255),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    gridlist2 = dgsCreateGridList (50*px, 30*py, 546*px, 408*py, false,rect2 )
    dgsGridListAddColumn( gridlist2, "Typ", 0.15 ) 
    dgsGridListAddColumn( gridlist2, "Powód", 0.5 ) 
    dgsGridListAddColumn( gridlist2, "Admin", 0.22 ) 
    dgsGridListAddColumn( gridlist2, "Data", 0.26 ) 
    triggerServerEvent("cmta_panelgracza:getacts", resourceRoot)

end
if source == button4 then
    removegui()

    for id,child in ipairs(dgsGetChildren(scrollpanel)) do
        destroyElement(child)
    end
    gridlistachievements = dgsCreateGridList (50*px, 30*py, 546*px, 348*py, false,rect2 )
    dgsGridListAddColumn( gridlistachievements, "", 0.1 ) 
    dgsGridListAddColumn( gridlistachievements, "Osiągnięcie", 0.50 ) 
    dgsGridListAddColumn( gridlistachievements, "Data zdobycia", 0.40 ) 

    dgsSetProperty(gridlistachievements,"rowHeight",30*py)
    dgsSetProperty(gridlistachievements, "font",font )


    dgsSetProperty(button4,"color",{tocolor(210,105,30,255),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    triggerServerEvent("cmta_panelgracza:getachievements", resourceRoot)

end
if source == button5 then
    removegui()
    dgsSetProperty(button5,"color",{tocolor(210,105,30,255),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    gridlistinventory = dgsCreateGridList (50*px, 30*py, 546*px, 348*py, false,rect2 )
    dgsGridListAddColumn( gridlistinventory, "", 0.1 ) 
    dgsGridListAddColumn( gridlistinventory, "Przedmiot", 0.50 ) 
    dgsGridListAddColumn( gridlistinventory, "Sztuki", 0.2 )
    dgsSetProperty(gridlistinventory,"rowHeight",30*py)
    dgsSetProperty(gridlistinventory, "font",font )

    button14 = dgsCreateButton( 100*px, 400*py, 180*px, 40*py, "Użyj", false,rect2,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
    button15 = dgsCreateButton( 366*px, 400*py, 180*px, 40*py, "Wyrzuć", false,rect2,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
    triggerServerEvent("cmta_panelgracza:getinventory", resourceRoot)
end
if source == button5ab then
    removegui()
    dgsSetProperty(button5ab,"color",{tocolor(210,105,30,255),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    edit3 = dgsCreateEdit( 100*px, 200*py, 446*px, 30*py, "Wprowadź kod...", false,rect2 )
    labelcodes = dgsCreateLabel(0*px,100*py,646*px,25*py,"Posiadasz kod bonusowy?\nWpisz go poniżej, aby odebrać nagrodę.\n\n#ff0000Pamiętaj, że wielkość liter ma znaczenie!",false,rect2)
    dgsSetFont( labelcodes, font )
    dgsSetProperty(labelcodes,"colorcoded",true)
    dgsSetProperty(labelcodes,"alignment",{"center","center"})
    button18 = dgsCreateButton( 200*px, 350*py, 246*px, 40*py, "Użyj", false,rect2,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
end
if source == button5b then
    removegui()
    dgsSetProperty(button5b,"color",{tocolor(210,105,30,255),tocolor(210,105,30,255),tocolor(210,105,30,255)})
    rndTest = dgsCreateRoundRect(0,false,tocolor(30,30,30,0))  
    recttest = dgsCreateImage(460*px,150*py,646*px,468*py,rndTest,false)

    for i,v in ipairs(shadery) do
        local bool = xmlNodeGetAttribute(xml,v[1])
        if tonumber(bool) == 1 then bool = true else bool = false end
        resetShader(v[1],bool)

        if not isElement(shader1) and i == 1 then
        shader1 = dgsCreateSwitchButton( 40*px, 30*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader2) and i == 2 then
        shader2 = dgsCreateSwitchButton( 40*px, 70*py, 50*px, 25*py, "", "", bool,false,recttest)
        end 
        if not isElement(shader3) and i == 3 then
        shader3 = dgsCreateSwitchButton( 40*px, 110*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader4) and i == 4 then
        shader4 = dgsCreateSwitchButton( 40*px, 150*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader5) and i == 5 then
        shader5 = dgsCreateSwitchButton( 40*px, 190*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader6) and i == 6 then
        shader6 = dgsCreateSwitchButton( 40*px, 230*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader7) and i == 7 then
        shader7 = dgsCreateSwitchButton( 40*px, 270*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader8) and i == 8 then
        shader8 = dgsCreateSwitchButton( 40*px, 310*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader9) and i == 9 then
        shader9 = dgsCreateSwitchButton( 40*px, 350*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader10) and i == 10 then
        shader10 = dgsCreateSwitchButton( 40*px, 390*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        if not isElement(shader11) and i == 11 then
        shader11 = dgsCreateSwitchButton( 40*px, 430*py, 50*px, 25*py, "", "", bool,false,recttest)
        end
        labelswitch = dgsCreateLabel(110*px,-10*py+((40*py)*i),110*px,25*py,v[2],false,recttest)
        dgsSetFont( labelswitch, font )
        dgsSetProperty(labelswitch,"colorcoded",true)
        dgsSetProperty(labelswitch,"alignment",{"left","center"})
    end
end

if source == shader1 then
if dgsSwitchButtonGetState(source) == false then
    setElementData(localPlayer,"shader:1",true)
    xmlNodeSetAttribute(xml,"shader:1",1)
	xmlSaveFile(xml)
else
    setElementData(localPlayer,"shader:1",false)
    xmlNodeSetAttribute(xml,"shader:1",0)
	xmlSaveFile(xml)
end
end
if source == shader2 then
    if dgsSwitchButtonGetState(source) == false then
        setElementData(localPlayer,"shader:2",true)
        xmlNodeSetAttribute(xml,"shader:2",1)
        xmlSaveFile(xml)
    else
        setElementData(localPlayer,"shader:2",false)
        xmlNodeSetAttribute(xml,"shader:2",0)
        xmlSaveFile(xml)
    end
    end
    if source == shader3 then
        if dgsSwitchButtonGetState(source) == false then
            setElementData(localPlayer,"shader:3",true)
            xmlNodeSetAttribute(xml,"shader:3",1)
            xmlSaveFile(xml)
        else
            setElementData(localPlayer,"shader:3",false)
            xmlNodeSetAttribute(xml,"shader:3",0)
            xmlSaveFile(xml)
        end
        end
        if source == shader4 then
            if dgsSwitchButtonGetState(source) == false then
                setElementData(localPlayer,"shader:4",true)
                xmlNodeSetAttribute(xml,"shader:4",1)
                xmlSaveFile(xml)
            else
                setElementData(localPlayer,"shader:4",false)
                xmlNodeSetAttribute(xml,"shader:4",0)
                xmlSaveFile(xml)
            end
            end
            if source == shader5 then
                if dgsSwitchButtonGetState(source) == false then
                    setElementData(localPlayer,"shader:5",true)
                    xmlNodeSetAttribute(xml,"shader:5",1)
                    xmlSaveFile(xml)
                else
                    setElementData(localPlayer,"shader:5",false)
                    xmlNodeSetAttribute(xml,"shader:5",0)
                    xmlSaveFile(xml)
                end
                end
if source == shader6 then
   if dgsSwitchButtonGetState(source) == false then
setElementData(localPlayer,"shader:6",true)
xmlNodeSetAttribute(xml,"shader:6",1)
xmlSaveFile(xml)
   else
setElementData(localPlayer,"shader:6",false)
xmlNodeSetAttribute(xml,"shader:6",0)
xmlSaveFile(xml)
   end
end

if source == shader7 then
    if dgsSwitchButtonGetState(source) == false then
        triggerEvent( "switchDynamicSky", root, true )
 xmlNodeSetAttribute(xml,"shader:7",1)
 xmlSaveFile(xml)
    else
        triggerEvent( "switchDynamicSky", root, false )
 xmlNodeSetAttribute(xml,"shader:7",0)
 xmlSaveFile(xml)
    end
 end

 if source == shader8 then
    if dgsSwitchButtonGetState(source) == false then
        exports["shader_drewnokomp"]:enablewood(resourceRoot,true)	
        xmlNodeSetAttribute(xml,"shader:8",1)
    xmlSaveFile(xml)
    else
        exports["shader_drewnokomp"]:enablewood(resourceRoot,false)	
        xmlNodeSetAttribute(xml,"shader:8",0)
    xmlSaveFile(xml)
    end
 end

if source == shader9 then
    if dgsSwitchButtonGetState(source) == false then
 setElementData(localPlayer,"shader:fps",true)
 xmlNodeSetAttribute(xml,"shader:fps",1)
 xmlSaveFile(xml)
    else
 setElementData(localPlayer,"shader:fps",false)
 xmlNodeSetAttribute(xml,"shader:fps",0)
 xmlSaveFile(xml)
    end
 end

 if source == shader10 then
    if dgsSwitchButtonGetState(source) == false then
        setFarClipDistance(7000)
        setCloudsEnabled(true)	
        setFogDistance(0) 
 xmlNodeSetAttribute(xml,"shader:renderowanie",1)
 xmlSaveFile(xml)
    else
        setFarClipDistance(650) 
        setCloudsEnabled(true)
        setFogDistance(150)
 xmlNodeSetAttribute(xml,"shader:renderowanie",0)
 xmlSaveFile(xml)
    end
 end

 if source == shader11 then
    if dgsSwitchButtonGetState(source) == false then
        setElementData(localPlayer,"showhud",true)
        showPlayerHudComponent("radar",false)
		showChat(false)
 xmlNodeSetAttribute(xml,"shader:ukrycie",1)
 xmlSaveFile(xml)
    else
        setElementData(localPlayer,"showhud",false)
        showPlayerHudComponent("radar",true)
		showChat(true)
 xmlNodeSetAttribute(xml,"shader:ukrycie",0)
 xmlSaveFile(xml)
    end
 end

if source == button6 then
    dgsSetAlpha ( rect1, 0.1 )
    dgsSetAlpha ( rect2, 0.1 )
    dgsSetEnabled ( rect1, false )
    dgsSetEnabled ( rect2, false )
    triggerServerEvent("cmta_panelgracza:listawspol", resourceRoot,idpojazdu)
    rect3 = dgsCreateImage(400*px,200*py,566*px,368*py,rndRect2,false)
    gridlist = dgsCreateGridList (80*px, 30*py, 406*px, 200*py, false,rect3 )
    dgsGridListAddColumn( gridlist, "Nick", 0.6 ) 
    dgsGridListAddColumn( gridlist, "UID", 0.3 ) 
    button8 = dgsCreateButton( 20*px, 300*py, 140*px, 40*py, "Dodaj", false,rect3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
    button9 = dgsCreateButton( 210*px, 300*py, 140*px, 40*py, "Usuń", false,rect3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
    button10 = dgsCreateButton( 406*px, 300*py, 140*px, 40*py, "Zamknij", false,rect3,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
end
if source == button7 then
    dgsSetAlpha ( rect1, 0.1 )
    dgsSetAlpha ( rect2, 0.1 )
    dgsSetEnabled ( rect1, false )
    dgsSetEnabled ( rect2, false )
    triggerServerEvent("cmta_panelgracza:pobierzhistorie", resourceRoot,idpojazdu)
    rect5 = dgsCreateImage(300*px,150*py,766*px,468*py,rndRect2,false)
    gridlistlogs = dgsCreateGridList (80*px, 30*py, 606*px, 300*py, false,rect5 )
    dgsGridListAddColumn( gridlistlogs, "Operacja", 0.6 ) 
    dgsGridListAddColumn( gridlistlogs, "Właściciel", 0.28 ) 
    dgsGridListAddColumn( gridlistlogs, "Czas", 0.25 ) 
    button13 = dgsCreateButton( 250*px, 400*py, 266*px, 40*py, "Zamknij", false,rect5,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))

end
if source == button8 then
    dgsSetVisible ( rect3, false )
    rect4 = dgsCreateImage(480*px,260*py,406*px,248*py,rndRect2,false)
    edit1 = dgsCreateEdit( 100*px, 80*py, 206*px, 30*py, "Tu wpisz nick/uid", false,rect4 )
    button11 = dgsCreateButton( 50*px, 170*py, 140*px, 40*py, "Dodaj", false,rect4,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
    button12 = dgsCreateButton( 216*px, 170*py, 140*px, 40*py, "Zamknij", false,rect4,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
end
if source == button9 then
    local selected = dgsGridListGetSelectedItem(gridlist)
    if selected ~= -1 then 
        triggerServerEvent("cmta_panelgracza:zabierzkluczyki", resourceRoot,selected,tabelawypozyczonych,idpojazdu)
    end
end
if source == button10 then
    dgsSetAlpha ( rect1, 0.8 )
    dgsSetAlpha ( rect2, 0.8 )
    dgsSetEnabled ( rect1, true )
    dgsSetEnabled ( rect2, true )
    destroyElement(rect3)
end
if source == button11 then
    local info = dgsGetText ( edit1 )
    if info == "Tu wpisz nick/uid" then return end
    triggerServerEvent("cmta_panelgracza:dodaj_wypozyczenie", resourceRoot, info,tabelawypozyczonych,idpojazdu)
end
if source == button12 then
    dgsSetVisible ( rect3, true )
    destroyElement(rect4)
end
if source == button13 then
    dgsSetAlpha ( rect1, 0.8 )
    dgsSetAlpha ( rect2, 0.8 )
    dgsSetEnabled ( rect1, true )
    dgsSetEnabled ( rect2, true )
    destroyElement(rect5)
end

if source == button15 then
    local selected = dgsGridListGetSelectedItem(gridlistinventory)
    if selected ~= -1 then 
        local nazwa= dgsGridListGetItemText(gridlistinventory,selected,2)
        local ilosc= dgsGridListGetItemText(gridlistinventory,selected,3)
        if tonumber(ilosc) == 1 then
            triggerServerEvent("cmta_panelgracza:ekwipunek_wyrzuc", resourceRoot, nazwa,1)
        else
            dgsSetAlpha ( rect1, 0.1 )
            dgsSetAlpha ( rect2, 0.1 )
            dgsSetEnabled ( rect1, false )
            dgsSetEnabled ( rect2, false )
            rect6 = dgsCreateImage(480*px,260*py,406*px,248*py,rndRect2,false)
            edit2 = dgsCreateEdit( 100*px, 80*py, 206*px, 30*py, ilosc, false,rect6 )
            button16 = dgsCreateButton( 50*px, 170*py, 140*px, 40*py, "Potwierdź", false,rect6,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
            button17 = dgsCreateButton( 216*px, 170*py, 140*px, 40*py, "Zamknij", false,rect6,false,false,false,false,false,false,false,tocolor(90,90,90),tocolor(210,105,30,255))
            labelinv = dgsCreateLabel(0*px,30*py,406*px,30*py,"#ff0000Wpisz ile sztuk chcesz wyrzucić",false,rect6)
            dgsSetFont( labelinv, font )
            dgsSetProperty(labelinv,"colorcoded",true)
            dgsSetProperty(labelinv,"alignment",{"center","center"})
        end
    end
end

if source == button16 then
    local selected = dgsGridListGetSelectedItem(gridlistinventory)
    if selected ~= -1 then
        local nazwa= dgsGridListGetItemText(gridlistinventory,selected,2)
        local ilosc= dgsGridListGetItemText(gridlistinventory,selected,3)

        if tonumber(dgsGetText ( edit2 )) <= 0 then return end
        if tonumber(dgsGetText ( edit2 )) > tonumber(ilosc) then return end
        triggerServerEvent("cmta_panelgracza:ekwipunek_wyrzuc", resourceRoot, nazwa,tonumber(dgsGetText ( edit2 )))
        dgsSetAlpha ( rect1, 0.8 )
        dgsSetAlpha ( rect2, 0.8 )
        dgsSetEnabled ( rect1, true )
        dgsSetEnabled ( rect2, true )
        destroyElement(rect6)
    end
end

if source == button17 then
    dgsSetAlpha ( rect1, 0.8 )
    dgsSetAlpha ( rect2, 0.8 )
    dgsSetEnabled ( rect1, true )
    dgsSetEnabled ( rect2, true )
    destroyElement(rect6)
end

if source == button18 then
    local code = dgsGetText ( edit3 )
    if code == "Wprowadź kod..." or string.len(code) < 8 then return end
    triggerServerEvent("cmta_panelgracza:bonuscode", resourceRoot, code)
end

end
end

addEvent("cmta_panelgracza:vehicles", true)
addEventHandler("cmta_panelgracza:vehicles", resourceRoot, function(result)
    for i,v in pairs(result) do
        if isElement(rect2) and dgsGetEnabled ( rect2 ) then
        dgsComboBoxAddItem(combobox, v["id"])
        end
    end
end)

function onselected(current,previous)
    if cmtaPANELGRACZA then
        dgsSetVisible(button6,false)
        dgsSetVisible(button7,false)
        local item = dgsComboBoxGetSelectedItem(combobox)
        if item ~= -1 then
            
	triggerServerEvent("cmta_panelgracza:getvehinfo", resourceRoot,dgsComboBoxGetItemText(combobox, current))
end
end
end
addEvent("cmta_panelgracza:vehinfo", true)
addEventHandler("cmta_panelgracza:vehinfo", resourceRoot, function(result,id)
    idpojazdu = id
    if isElement(vehimg) then
        if isElement(veh) then destroyElement(veh) end
        dgsRemoveObjectPreviewFromImage(vehimg)
        exports.object_preview:destroyObjectPreview(vehPrev)
        destroyElement(vehimg)
    end
    veh = createVehicle(result[1]["model"],0,0,3)
    vehPrev = dgsCreateObjectPreviewHandle(veh,0,0,0)
    exports.object_preview:setRotation(vehPrev,-10,0,140)
    vehimg = dgsCreateImage(400*px,0*py,250*px,250*py,_,false,rect2)
    dgsAttachObjectPreviewToImage(vehPrev,vehimg)

    for i,v in pairs(result) do
        if v["colorspeedo"] == "fiolet" then addon1 = "Kolor licznika #8A00FF█#808080," elseif v["colorspeedo"] == "czerw" then addon1 = "Kolor licznika #ff0000█#808080," elseif v["colorspeedo"] == "nieb" then addon1 = "Kolor licznika #0000ff█#808080," elseif v["colorspeedo"] == "zolty" then addon1 = "Kolor licznika #ffff00█#808080," elseif v["colorspeedo"] == "roz" then addon1 = "Kolor licznika #ff00ff█#808080," elseif v["colorspeedo"] == "turkus" then addon1 = "Kolor licznika #00ffff█#808080," elseif v["colorspeedo"] == "pom" then addon1 = "Kolor licznika #FF6000█#808080," elseif v["colorspeedo"] == "fiolet" then addon1 = "Kolor licznika #8A00FF█#808080," elseif v["colorspeedo"] == "zielone" then addon1 = "Kolor licznika #03A700█#808080," elseif v["colorspeedo"] == "blekit" then addon1 = "Kolor licznika #005CFF█#808080," elseif v["colorspeedo"] == "czarny" then addon1 = "Kolor licznika #000000█#808080," else addon1 = "" end
        if v["mk1"] == 1 then addon2 = "#ff2828Mk1#808080," else addon2 = "" end
        if v["mk2"] == 1 then addon3 = "#ff2828Mk2#808080," else addon3 = "" end
        if v["mk3"] == 1 then addon4 = "#ff2828Mk3#808080," else addon4 = "" end
        if v["esp"] == 1 then addon6 = "#ff2828ESP#808080," else addon6 = "" end
        if v["LaunchControl"] == 1 then addon5 = "#ff2828Launch Control#808080," else addon5 = "" end
        local addons = ""..addon1..""..addon2..""..addon3..""..addon4..""..addon5..""..addon6..""
        dgsSetText(text2,"#808080Model: #ff2828"..getVehicleNameFromModel(v["model"]).." [ID:"..v["id"].."]\n#808080Przebieg: #ff2828"..v["mileage"].." #808080kilometrów\n#808080Pojemność silnika: #ff2828"..v["engine"].." cm³\n#808080Typ silnika: #ff2828"..v["engineType"].."\n#808080Pojemność baku: #ff2828"..v["tank"].."L\n#808080Dodatki: #ff2828"..addons.."")
        local color=split(v["color"], ",")
        setVehicleColor(veh,color[1],color[2],color[3])
    end
    for i,v in pairs(getElementsByType("vehicle")) do
        if tonumber(getElementData(v,"vehicle:id")) == tonumber(id) then
            local x,y,z = getElementPosition(v)
            if getElementData(v,"vehicle:colorspeedo") == "fiolet" then addon1 = "Kolor licznika #8A00FF█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "czerw" then addon1 = "Kolor licznika #ff0000█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "nieb" then addon1 = "Kolor licznika #0000ff█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "zolty" then addon1 = "Kolor licznika #ffff00█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "roz" then addon1 = "Kolor licznika #ff00ff█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "turkus" then addon1 = "Kolor licznika #00ffff█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "pom" then addon1 = "Kolor licznika #FF6000█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "fiolet" then addon1 = "Kolor licznika #8A00FF█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "zielone" then addon1 = "Kolor licznika #03A700█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "blekit" then addon1 = "Kolor licznika #005CFF█#808080," elseif getElementData(v,"vehicle:colorspeedo") == "czarny" then addon1 = "Kolor licznika #000000█#808080," else addon1 = "" end
            if getElementData(v,"vehicle:mk1") == 1 then addon2 = "#ff2828Mk1#808080," else addon2 = "" end
            if getElementData(v,"vehicle:mk2") == 1 then addon3 = "#ff2828Mk2#808080," else addon3 = "" end
            if getElementData(v,"vehicle:mk3") == 1 then addon4 = "#ff2828Mk3#808080," else addon4 = "" end
            if getElementData(v,"vehicle:esp") then addon6 = "#ff2828ESP#808080," else addon6 = "" end
            if getElementData(v,"vehicle:launchcontrol") == 1 then addon5 = "#ff2828Launch Control#808080," else addon5 = "" end
            local addons = ""..addon1..""..addon2..""..addon3..""..addon4..""..addon5..""..addon6..""
            dgsSetText(text2,"#808080Model: #ff2828"..getVehicleName(v).." [ID:"..getElementData(v,"vehicle:id").."]\n#808080Przebieg: #ff2828"..getElementData(v,"vehicle:mileage").." #808080kilometrów\nLokalizacja: #ff2828"..string.format("%.2f",x)..", "..string.format("%.2f",y)..", "..string.format("%.2f",z).."\n#808080Pojemność silnika: #ff2828"..getElementData(v,"vehicle:engine").." cm³\n#808080Typ silnika: #ff2828"..getElementData(v,"vehicle:engineType").."\n#808080Pojemność baku: #ff2828"..getElementData(v,"vehicle:tank").."L\n#808080Dodatki: #ff2828"..addons.."")
            local c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12 = getVehicleColor ( v )
            setVehicleColor(veh,c1,c2,c3,c4,c5,c6)

        end
    end
    dgsSetVisible(button6,true)
    dgsSetVisible(button7,true)
end)

addEvent("cmta_panelgracza:listakluczy", true)
addEventHandler("cmta_panelgracza:listakluczy", resourceRoot, function(uid,real)
  dgsGridListClear(gridlist)
  tabelawypozyczonych = real
  for i,v in pairs(uid) do
    local row = dgsGridListAddRow ( gridlist )
    dgsGridListSetItemText ( gridlist, row, 1, v[2] )
    dgsGridListSetItemText ( gridlist, row, 2, v[1] )
  end
end)

addEvent("cmta_panelgracza:refreshlista", true)
addEventHandler("cmta_panelgracza:refreshlista", resourceRoot, function(id)
	triggerServerEvent("cmta_panelgracza:listawspol", resourceRoot,tonumber(id))
end)

addEvent("cmta_panelgracza:playerinfo", true)
addEventHandler("cmta_panelgracza:playerinfo", resourceRoot, function(result,result2,result3)
    skin = createPed(getElementModel(localPlayer),0,0,3)
    objPrev = dgsCreateObjectPreviewHandle(skin,0,0,0)
    exports.object_preview:setRotation(objPrev,0,0,180)
    pedimg = dgsCreateImage(-100*px,0*py,400*px,438*py,_,false,rect2)
    dgsAttachObjectPreviewToImage(objPrev,pedimg)
panelgraczaPREMIUM = result
panelgraczaLIMIT = result2
panelgraczaVEHICLES = result3

if getElementData(localPlayer,"player:data").vip then
    konto = "#ccc000V.I.P"
    datakonta = "#ccc000V.I.P#808080 ważny do: #ff2828"..(panelgraczaPREMIUM or "").."\n"
else
    konto = "#ff2828Zwykłe"
    datakonta = ""
end

if isElement(text) then dgsSetText(text,"#808080Nick: #ff2828"..getPlayerName(localPlayer).."\n#808080Status konta: "..konto.."\n"..datakonta.."#808080UID: #ff2828"..(getElementData(localPlayer,"player:data").uid).."\n#808080Punkty: #ff2828"..(getElementData(localPlayer,"player:data").points).."\n#808080Poziom: #ff2828"..(getElementData(localPlayer,"player:data").lvl).."\n#808080Exp: #ff2828"..(getElementData(localPlayer,"player:data").exp).."/"..(getElementData(localPlayer,"player:data").requestexp).."\n#808080Punkty osiągnięć: #ff2828"..(getElementData(localPlayer,"player:data").PO).."\n#808080Przegrany czas: #ff2828"..(getElementData(localPlayer,"player:data").timeplayed).." #808080minut\nGang: #ff2828"..((getElementData(localPlayer,"player:data").gang) or "Brak").."\n#808080Liczba pojazdów: #ff2828 "..(panelgraczaVEHICLES or "").."/"..(panelgraczaLIMIT or "").."") end 
end)

addEvent("cmta_panelgracza:acts", true)
addEventHandler("cmta_panelgracza:acts", resourceRoot, function(result)
  if not isElement(gridlist2) then return end
  dgsGridListClear(gridlist2)
  for i,v in pairs(result) do
    local row = dgsGridListAddRow ( gridlist2 )
    dgsGridListSetItemText ( gridlist2, row, 1, v["type"] )
    dgsGridListSetItemText ( gridlist2, row, 2, v["reason"] )
    dgsGridListSetItemText ( gridlist2, row, 3, v["admin"] )
    dgsGridListSetItemText ( gridlist2, row, 4, v["time"] )
    if v["type"] == "prawo jazdy" then
        dgsGridListSetRowBackGroundColor(gridlist2,row,tocolor(238,130,238,120),tocolor(238,130,238,120),tocolor(238,130,238,120))
    end
    if v["type"] == "wyrzucenie" then
        dgsGridListSetRowBackGroundColor(gridlist2,row,tocolor(255,165,0,120),tocolor(255,165,0,120),tocolor(255,165,0,120))
    end
    if v["type"] == "ban" then
        dgsGridListSetRowBackGroundColor(gridlist2,row,tocolor(255,0,0,120),tocolor(255,0,0,120),tocolor(255,0,0,120))
    end
    if v["type"] == "wyciszenie" then
        dgsGridListSetRowBackGroundColor(gridlist2,row,tocolor(46,139,87,120),tocolor(46,139,87,120),tocolor(46,139,87,120))
    end
    if v["type"] == "blokada konta" then
        dgsGridListSetRowBackGroundColor(gridlist2,row,tocolor(0,0,0,120),tocolor(0,0,0,120),tocolor(0,0,0,120))
    end    
    if v["type"] == "ostrzeżenie" then
        dgsGridListSetRowBackGroundColor(gridlist2,row,tocolor(200,139,87,120),tocolor(200,139,87,120),tocolor(200,139,87,120))
    end
  end
end)


addEventHandler( "onClientResourceStart", getRootElement( ),
    function (  )
        for i,v in ipairs(shadery) do
            local bool = xmlNodeGetAttribute(xml,v[1])
            if tonumber(bool) == 1 then bool = true else bool = false end
            resetShader(v[1],bool)
        end
    end
)

function resetShader(i,bool)
    if i == "shader:7" then
    triggerEvent( "switchDynamicSky", root, bool )
    elseif i == "shader:8" then
	exports["shader_drewnokomp"]:enablewood(resourceRoot,bool)	
    elseif i == "shader:renderowanie" then
        if bool == true then
            setFarClipDistance(7000)
			setCloudsEnabled(true)	
			setFogDistance(0) 
        else
			setFarClipDistance(650) 
			setCloudsEnabled(true)
			setFogDistance(150)
        end
    elseif i == "shader:ukrycie" then
        if bool == true then
            showPlayerHudComponent("radar",false)
            showChat(false)
            setElementData(localPlayer,i,bool)
        else
            showPlayerHudComponent("radar",true)
            showChat(true)
            setElementData(localPlayer,i,bool)
        end
    else
    setElementData(localPlayer,i,bool)
    end
    if bool == true then bool2 = 1 else bool2 = 0 end
    xmlNodeSetAttribute(xml,i,bool2)
	xmlSaveFile(xml)
end

addEvent("cmta_panelgracza:historia", true)
addEventHandler("cmta_panelgracza:historia", resourceRoot, function(result)
  dgsGridListClear(gridlistlogs)
  for i,v in pairs(result) do
    local row = dgsGridListAddRow ( gridlistlogs )
    dgsGridListSetItemText ( gridlistlogs, row, 1, v["operation"] )
    dgsGridListSetItemText ( gridlistlogs, row, 2, ""..v["nameowner"].." ["..v["idowner"].."]")
    dgsGridListSetItemText ( gridlistlogs, row, 3, v["time"] )
    dgsGridListSetRowBackGroundColor(gridlistlogs,row,false,false,false)

  if v["idowner"] == getElementData(localPlayer,"player:data").uid then
    dgsGridListSetRowBackGroundColor(gridlistlogs,row,tocolor(165,42,42,120),tocolor(165,42,42,120),tocolor(165,42,42,120))
  end
  end

end)

function createImageInventory()
    invimg1 = dxCreateTexture( "ekwipunek/papierosy.png" ,"argb", false, "clamp" )
    invimg2 = dxCreateTexture( "ekwipunek/marihuana.png" ,"argb", false, "clamp" )
    invimg3 = dxCreateTexture( "ekwipunek/kanister.png" ,"argb", false, "clamp" )
    invimg4 = dxCreateTexture( "ekwipunek/kuponsalon.png" ,"argb", false, "clamp" )
    invimg5 = dxCreateTexture( "ekwipunek/tyton.png" ,"argb", false, "clamp" )
    invimg6 = dxCreateTexture( "ekwipunek/klucz1.png" ,"argb", false, "clamp" )
    invimg7 = dxCreateTexture( "ekwipunek/klucz2.png" ,"argb", false, "clamp" )
    invimg8 = dxCreateTexture( "ekwipunek/klucz3.png" ,"argb", false, "clamp" )
    invimg9 = dxCreateTexture( "ekwipunek/klucz4.png" ,"argb", false, "clamp" )
    invimg10 = dxCreateTexture( "ekwipunek/klucz5.png" ,"argb", false, "clamp" )
    invimg11 = dxCreateTexture( "ekwipunek/klucz6.png" ,"argb", false, "clamp" )
    invimg12 = dxCreateTexture( "ekwipunek/klucz7.png" ,"argb", false, "clamp" )
    invimg13 = dxCreateTexture( "ekwipunek/klucz8.png" ,"argb", false, "clamp" )
    invimg14 = dxCreateTexture( "ekwipunek/vip1.png" ,"argb", false, "clamp" )
    invimg15 = dxCreateTexture( "ekwipunek/vip2.png" ,"argb", false, "clamp" )
    invimg16 = dxCreateTexture( "ekwipunek/vip3.png" ,"argb", false, "clamp" )
end

function destroyImageInventory()
    if isElement( invimg1) then destroyElement(invimg1) end
    if isElement( invimg2) then destroyElement(invimg2) end
    if isElement( invimg3) then destroyElement(invimg3) end
    if isElement( invimg4) then destroyElement(invimg4) end
    if isElement( invimg5) then destroyElement(invimg5) end
    if isElement( invimg6) then destroyElement(invimg6) end
    if isElement( invimg7) then destroyElement(invimg7) end
    if isElement( invimg8) then destroyElement(invimg8) end
    if isElement( invimg9) then destroyElement(invimg9) end
    if isElement( invimg10) then destroyElement(invimg10) end
    if isElement( invimg11) then destroyElement(invimg11) end
    if isElement( invimg12) then destroyElement(invimg12) end
    if isElement( invimg13) then destroyElement(invimg13) end
    if isElement( invimg14) then destroyElement(invimg14) end
    if isElement( invimg15) then destroyElement(invimg15) end
    if isElement( invimg16) then destroyElement(invimg16) end
end


addEvent("cmta_panelgracza:inventory", true)
addEventHandler("cmta_panelgracza:inventory", resourceRoot, function(result)
  if not isElement(gridlistinventory) then return end
  dgsGridListClear(gridlistinventory)
  destroyImageInventory()
  createImageInventory()
  for i,v in pairs(result) do
    if v["cigarettes"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg1,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Papierosy" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["cigarettes"] )
    end
    if v["marihuana"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg2,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Marihuana" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["marihuana"] )
    end
    if v["fuel"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg3,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Kanister z paliwem (1 szt = 1 litr)" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["fuel"] )
    end
    if v["vehcoupon"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg4,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Kupon -10% na pojazd z salonu" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["vehcoupon"] )
    end
    if v["tobacco"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg5,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Tytoń" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["tobacco"] )
    end
    if v["key1"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg6,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Klucz do Skrzyni Różności" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["key1"] )
    end
    if v["key2"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg7,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Klucz do Skrzyni Różności VIP" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["key2"] )
    end
    if v["key3"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg8,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Klucz do Skrzyni Pojazdów" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["key3"] )
    end
    if v["key4"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg9,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Klucz do Skrzyni Broni" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["key4"] )
    end
    if v["key5"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg10,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Klucz do Skrzyni Ryzyka" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["key5"] )
    end
    if v["key6"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg11,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Klucz do Skrzyni VIP" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["key6"] )
    end
    if v["key7"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg12,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Klucz do Skrzyni Gangstera" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["key7"] )
    end
    if v["key8"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg13,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Klucz do Skrzyni Pół na Pół" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["key8"] )
    end
    if v["vip3"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg14,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Kupon na konto VIP (3 dni)" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["vip3"] )
    end
    if v["vip7"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg15,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Kupon na konto VIP (7 dni)" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["vip7"] )
    end
    if v["vip14"] > 0 then
        local row = dgsGridListAddRow ( gridlistinventory )
        dgsGridListSetItemImage( gridlistinventory, row, 1, invimg16,tocolor(255,255,255,255),5*px,3*py,24*px,24*py,false)
        dgsGridListSetItemText ( gridlistinventory, row, 2, "Kupon na konto VIP (14 dni)" )
        dgsGridListSetItemText ( gridlistinventory, row, 3, v["vip14"] )
    end
  end
end)